點我下載:song_rank3.csv
setwd('/Users/carplee/Desktop/files/IT python')
p = read.csv('data/song_rank3.csv')

a2 = p$art2!=""

p[a2, ]
   Rank  Hits         Song Co      art1   art2
2     2 74629        勇氣  是    魏嘉瑩 魏如昀
3     3 62531 沒什麼大不了 是    陳芳語 茄子蛋
4     4 38971          我  是    蕭敬騰   馬佳
6     6  7023  愛情限時批  是 琳誼 Ring 許富凱
13   13  2222        力量  是    魏嘉瑩 魏如昀
14   14  1083       很重要 是    陳芳語 茄子蛋
              Artist       Date
2     魏嘉瑩, 魏如昀 2021-07-27
3    陳芳語 , 茄子蛋 2021-08-06
4       蕭敬騰, 馬佳 2021-08-06
6  琳誼 Ring, 許富凱 2021-08-01
13    魏嘉瑩, 魏如昀 2021-07-12
14   陳芳語 , 茄子蛋 2021-08-09
                                                                    Url
2  https://www.kkbox.com/tw/tc/song/PLQ004POLLr78J1P78J1P0XL-index.html
3  https://www.kkbox.com/tw/tc/song/uX800A9O0.rHGjNHHGjNH0XL-index.html
4  https://www.kkbox.com/tw/tc/song/kZd00W8WP.rkDPo9kDPo90XL-index.html
6  https://www.kkbox.com/tw/tc/song/Gpb00L-OOTrXdqOPXdqOP0XL-index.html
13 https://www.kkbox.com/tw/tc/song/PLQ004POLLr78J1P78J1P0XL-index.html
14 https://www.kkbox.com/tw/tc/song/uX800A9O0.rHGjNHHGjNH0XL-index.html
   Artist2
2        0
3        0
4        0
6        0
13       0
14       0
library(dplyr)
count(p[a2,])
  n
1 6
count(p[!a2,])
  n
1 8
single = as.numeric(count(p[a2,]))
co = as.numeric(count(p[!a2,]))
single 6
co 8
library(ggplot2)
x = c("獨唱","合唱")
y = c(single, co)
df = data.frame(type=x, cnt=y)

ggplot(df, aes(type,cnt))+geom_col()

ggplot(df, aes(type, cnt))+geom_bar(stat = 'identity')
ggplot(df, aes(type,cnt))+
  geom_col()+
  theme(text = element_text(family = "Heiti TC"))

ggplot(df, aes(type,cnt))+
  geom_col(width=0.5)+
  theme(text = element_text(family = "Heiti TC"))

ggplot(df, aes(type,cnt))+
  geom_col(width=0.5, just = 1)+
  theme(text = element_text(family = "Heiti TC"))

ggplot(df, aes(type,cnt))+
  geom_col(width=0.5, just = 1)+
  ggtitle(label = "華語歌曲榜統計")+
  theme(text = element_text(family = "Heiti TC"))

ggplot(df, aes(type,cnt))+
  geom_col(width=0.5, just = 1)+
  ggtitle(label = "華語歌曲榜統計")+
  xlab('歌曲分類') +
  theme(text = element_text(family = "Heiti TC"))

ggplot(df, aes(type,cnt))+
  geom_col(width=0.5, just = 1)+
  ggtitle(label = "華語歌曲榜統計")+
  xlab('歌曲分類') +
  ylab('數量') +
  theme(text = element_text(family = "Heiti TC"))  

ggplot(df, aes(type,cnt))+
  geom_col(width=0.5, just = 1)+
  ggtitle(label = "華語歌曲榜統計")+
  xlab('歌曲分類') +
  ylab('數量') +
  theme(text = element_text(family = "Heiti TC"),
        axis.title.y = element_text(angle=0))  
